package com.example.demo.listener;

import com.example.demo.event.UserMailEvent;
import com.example.demo.event.UserRegisterEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @Description : 监听器
 * @Author : Bruce Lee
 * @CreateTime : 2024/3/27
 */


@Component
public class MyRegisterListener {

    @EventListener(UserRegisterEvent.class)
    public void onApplicationEvent(UserRegisterEvent event)
    {
        System.out.println("监听到事件：" + event.getUser().getUsername());
    }


    @EventListener(UserMailEvent.class)
    public void onApplicationEvent(UserMailEvent event)
    {
        System.out.println("监听到事件(@EventListener监听)：" + event.getEmail().getSender());
    }
}
